<template>
  <router-view />
</template>

<script setup>
import useSettingsStore from "@/store/modules/settings";
import { handleThemeStyle } from "@/utils/theme";
import Cookies from "js-cookie";

const { proxy } = getCurrentInstance();
onMounted(() => {
  nextTick(() => {
    // ��ʼ��������ʽ
    handleThemeStyle(useSettingsStore().theme);
    setColor()
    updatePinformationStyle();
  });
});

function updatePinformationStyle() {
  const rootElement = document.documentElement;
  let size = Cookies.get("size");
  if (!size) {
    Cookies.set("size", "default", { expires: 30 });
  } else {
    Cookies.set("size", size, { expires: 30 });
  }
  if (Cookies.get("size") === "small") {
    rootElement.style.setProperty("--pinformation-font-size", "12px");
  } else if (Cookies.get("size") === "default") {
    rootElement.style.setProperty("--pinformation-font-size", "14px");
  } else {
    rootElement.style.setProperty("--pinformation-font-size", "16px");
  }
  let tokenParams = window.external.UserParams;
  if (tokenParams && tokenParams.split("φ")[1] == "pageOffice") {
    return Cookies.set("Admin-Token", tokenParams.split("φ")[0])
  }
}

function setColor() {
  const rootElement = document.documentElement;
  rootElement.style.setProperty("--theme-deep-color", "#1E90FF");
  rootElement.style.setProperty("--theme-light-color", "#87CEFA");
  rootElement.style.setProperty("--theme-light-disabled-color", "#2071a4");
}
</script>
